//
//  Posts.m
//  __PRODUCTNAME__
//
//  Created by Hanlingyu on 16/08/30
//  Copyright (c) ltq. All rights reserved.
//

#import "Posts.h"
#import "Img.h"
#import "Hotcomments.h"

@implementation Posts

- (void)setValue:(id)value forKey:(NSString *)key {
    
    if ([key isEqualToString:@"img"]) {
        
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            Img *img = [Img modelWithDic:dic];
            [array addObject:img];
        }
        _img = array;
        
    } else if ([key isEqualToString:@"hotComments"]) {
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            Hotcomments *hotcomment = [Hotcomments modelWithDic:dic];
            [array addObject:hotcomment];
        }
        _hotComments = array;
        
    } else {
        
        [super setValue:value forKey:key];
    }
    
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    [super setValue:value forUndefinedKey:key];
    if ([key isEqualToString:@"id"]) {
        _ID = value;
    }
    
}



+ (NSDictionary *)objectClassInArray{
    return @{@"img" : [Img class], @"hotComments" : [Hotcomments class]};
}

@end
